home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / rampart.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  21KB  |  713 lines

  1. /***************************************************************************
  2.  
  3.     Rampart
  4.  
  5.     driver by Aaron Giles
  6.  
  7. ****************************************************************************/
  8.  
  9.  
  10. #include "driver.h"
  11. #include "machine/atarigen.h"
  12. #include "vidhrdw/generic.h"
  13.  
  14.  
  15. WRITE_HANDLER( rampart_playfieldram_w );
  16.  
  17. int rampart_vh_start(void);
  18. void rampart_vh_stop(void);
  19. void rampart_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  20.  
  21. void rampart_scanline_update(int scanline);
  22.  
  23.  
  24. static UINT8 *slapstic_base;
  25. static UINT32 current_bank;
  26.  
  27.  
  28.  
  29. /*************************************
  30.  *
  31.  *    Interrupt handling
  32.  *
  33.  *************************************/
  34.  
  35. static void update_interrupts(void)
  36. {
  37.     int newstate = 0;
  38.  
  39.     if (atarigen_scanline_int_state)
  40.         newstate = 4;
  41.  
  42.     if (newstate)
  43.         cpu_set_irq_line(0, newstate, ASSERT_LINE);
  44.     else
  45.         cpu_set_irq_line(0, 7, CLEAR_LINE);
  46. }
  47.  
  48.  
  49. static void scanline_update(int scanline)
  50. {
  51.     /* update video */
  52.     rampart_scanline_update(scanline);
  53.  
  54.     /* generate 32V signals */
  55.     if (scanline % 64 == 0)
  56.         atarigen_scanline_int_gen();
  57. }
  58.  
  59.  
  60.  
  61. /*************************************
  62.  *
  63.  *    Slapstic fun & joy
  64.  *
  65.  *************************************/
  66.  
  67. static UINT32 bank_list[] = { 0x4000, 0x6000, 0x0000, 0x2000 };
  68.  
  69. static READ_HANDLER( slapstic_bank_r )
  70. {
  71.     int opcode_pc = cpu_getpreviouspc();
  72.     int result;
  73.  
  74.     /* if the previous PC was 1400E6, then we will be passing through 1400E8 as
  75.        we decode this instruction. 1400E8 -> 0074 which represents a significant
  76.        location on the Rampart slapstic; best to tweak it here */
  77.     if (opcode_pc == 0x1400e6)
  78.     {
  79.         current_bank = bank_list[slapstic_tweak(0x00e6 / 2)];
  80.         current_bank = bank_list[slapstic_tweak(0x00e8 / 2)];
  81.         current_bank = bank_list[slapstic_tweak(0x00ea / 2)];
  82.     }
  83.  
  84.     /* tweak the slapstic and adjust the bank */
  85.     current_bank = bank_list[slapstic_tweak(offset / 2)];
  86.     result = READ_WORD(&slapstic_base[current_bank + (offset & 0x1fff)]);
  87.  
  88.     /* if we did the special hack above, then also tweak for the following
  89.        instruction fetch, which will force the bank switch to occur */
  90.     if (opcode_pc == 0x1400e6)
  91.         current_bank = bank_list[slapstic_tweak(0x00ec / 2)];
  92.  
  93.     /* adjust the bank and return the result */
  94.     return result;
  95. }
  96.  
  97. static WRITE_HANDLER( slapstic_bank_w )
  98. {
  99. }
  100.  
  101.  
  102. static OPBASE_HANDLER( opbase_override )
  103. {
  104.     int oldpc = cpu_getpreviouspc();
  105.  
  106.     /* tweak the slapstic at the source PC */
  107.     if (oldpc >= 0x140000 && oldpc < 0x148000)
  108.         slapstic_bank_r(oldpc - 0x140000);
  109.  
  110.     /* tweak the slapstic at the destination PC */
  111.     if (address >= 0x140000 && address < 0x148000)
  112.     {
  113.         current_bank = bank_list[slapstic_tweak((address - 0x140000) / 2)];
  114.  
  115.         /* use a bogus ophw so that we will be called again on the next jump/ret */
  116.         catch_nextBranch();
  117.  
  118.         /* compute the new ROM base */
  119.         OP_RAM = OP_ROM = &slapstic_base[current_bank] - 0x140000;
  120.  
  121.         /* return -1 so that the standard routine doesn't do anything more */
  122.         address = -1;
  123.  
  124.         logerror("Slapstic op override at %06X\n", address);
  125.     }
  126.  
  127.     return address;
  128. }
  129.  
  130.  
  131.  
  132. /*************************************
  133.  *
  134.  *    Initialization
  135.  *
  136.  *************************************/
  137.  
  138. static void init_machine(void)
  139. {
  140.     atarigen_eeprom_reset();
  141.     slapstic_reset();
  142.     atarigen_interrupt_reset(update_interrupts);
  143.     atarigen_scanline_timer_reset(scanline_update, 8);
  144. }
  145.  
  146.  
  147.  
  148. /*************************************
  149.  *
  150.  *    MSM5295 I/O
  151.  *
  152.  *************************************/
  153.  
  154. static READ_HANDLER( adpcm_r )
  155. {
  156.     return (OKIM6295_status_0_r(offset) << 8) | 0x00ff;
  157. }
  158.  
  159.  
  160. static WRITE_HANDLER( adpcm_w )
  161. {
  162.     if (!(data & 0xff000000))
  163.         OKIM6295_data_0_w(offset, (data >> 8) & 0xff);
  164. }
  165.  
  166.  
  167.  
  168. /*************************************
  169.  *
  170.  *    YM2413 I/O
  171.  *
  172.  *************************************/
  173.  
  174. static READ_HANDLER( ym2413_r )
  175. {
  176.     (void)offset;
  177.     return (YM2413_status_port_0_r(0) << 8) | 0x00ff;
  178. }
  179.  
  180.  
  181. static WRITE_HANDLER( ym2413_w )
  182. {
  183.     if (!(data & 0xff000000))
  184.     {
  185.         if (offset & 2)
  186.             YM2413_data_port_0_w(0, (data >> 8) & 0xff);
  187.         else
  188.             YM2413_register_port_0_w(0, (data >> 8) & 0xff);
  189.     }
  190. }
  191.  
  192.  
  193.  
  194. /*************************************
  195.  *
  196.  *    Latch write
  197.  *
  198.  *************************************/
  199.  
  200. static WRITE_HANDLER( latch_w )
  201. {
  202.     (void)offset;
  203.     /* bit layout in this register:
  204.  
  205.         0x8000 == VCR ???
  206.         0x2000 == LETAMODE1 (controls right trackball)
  207.         0x1000 == CBANK (color bank -- is it ever set to non-zero?)
  208.         0x0800 == LETAMODE0 (controls center and left trackballs)
  209.         0x0400 == LETARES (reset LETA analog control reader)
  210.  
  211.         0x0020 == PMIX0 (ADPCM mixer level)
  212.         0x0010 == /PCMRES (ADPCM reset)
  213.         0x000E == YMIX2-0 (YM2413 mixer level)
  214.         0x0001 == /YAMRES (YM2413 reset)
  215.     */
  216.  
  217.     /* upper byte being modified? */
  218.     if (!(data & 0xff000000))
  219.     {
  220.         if (data & 0x1000)
  221.             logerror("Color bank set to 1!\n");
  222.     }
  223.  
  224.     /* lower byte being modified? */
  225.     if (!(data & 0x00ff0000))
  226.     {
  227.         atarigen_set_ym2413_vol(((data >> 1) & 7) * 100 / 7);
  228.         atarigen_set_oki6295_vol((data & 0x0020) ? 100 : 0);
  229.     }
  230. }
  231.  
  232.  
  233.  
  234. /*************************************
  235.  *
  236.  *    Main CPU memory handlers
  237.  *
  238.  *************************************/
  239.  
  240. static struct MemoryReadAddress readmem[] =
  241. {
  242.     { 0x000000, 0x0fffff, MRA_ROM },
  243.     { 0x140000, 0x147fff, slapstic_bank_r },
  244.     { 0x200000, 0x21fffe, MRA_BANK1 },
  245.     { 0x3c0000, 0x3c07ff, MRA_BANK2 },
  246.     { 0x3e0000, 0x3effff, MRA_BANK3 },
  247.     { 0x460000, 0x460001, adpcm_r },
  248.     { 0x480000, 0x480001, ym2413_r },
  249.     { 0x500000, 0x500fff, atarigen_eeprom_r },
  250.     { 0x640000, 0x640001, input_port_0_r },
  251.     { 0x640002, 0x640003, input_port_1_r },
  252.     { 0x6c0000, 0x6c0001, input_port_2_r },
  253.     { 0x6c0002, 0x6c0003, input_port_3_r },
  254.     { 0x6c0004, 0x6c0005, input_port_4_r },
  255.     { 0x6c0006, 0x6c0007, input_port_5_r },
  256.     { 0x6c0008, 0x6c0009, input_port_6_r },
  257.     { 0x6c000a, 0x6c000b, input_port_7_r },
  258.     { -1 }  /* end of table */
  259. };
  260.  
  261.  
  262. static struct MemoryWriteAddress writemem[] =
  263. {
  264.     { 0x000000, 0x0fffff, MWA_ROM },
  265.     { 0x140000, 0x147fff, slapstic_bank_w, &slapstic_base },    /* here only to initialize the pointer */
  266.     { 0x200000, 0x21fffe, rampart_playfieldram_w, &atarigen_playfieldram },
  267.     { 0x220000, 0x3bffff, MWA_NOP },    /* the code blasts right through this when initializing */
  268.     { 0x3c0000, 0x3c07ff, atarigen_expanded_666_paletteram_w, &paletteram },
  269.     { 0x3c0800, 0x3dffff, MWA_NOP },    /* the code blasts right through this when initializing */
  270.     { 0x3e0000, 0x3effff, MWA_BANK3, &atarigen_spriteram },
  271.     { 0x460000, 0x460001, adpcm_w },
  272.     { 0x480000, 0x480003, ym2413_w },
  273.     { 0x500000, 0x500fff, atarigen_eeprom_w, &atarigen_eeprom, &atarigen_eeprom_size },
  274.     { 0x5a0000, 0x5affff, atarigen_eeprom_enable_w },
  275.     { 0x640000, 0x640001, latch_w },
  276.     { 0x720000, 0x72ffff, watchdog_reset_w },
  277.     { 0x7e0000, 0x7effff, atarigen_scanline_int_ack_w },
  278.     { -1 }  /* end of table */
  279. };
  280.  
  281.  
  282.  
  283. /*************************************
  284.  *
  285.  *    Port definitions
  286.  *
  287.  *************************************/
  288.  
  289. //coin1: was 640013,0; rampart 640003,2
  290. //coin2: was 640013,1; rampart 640003,1
  291.  
  292. INPUT_PORTS_START( rampart )
  293.     PORT_START
  294.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED )
  295.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
  296.     PORT_BITX(  0x0004, 0x0004, IPT_DIPSWITCH_NAME, "Number of Players", IP_KEY_NONE, IP_JOY_NONE )
  297.     PORT_DIPSETTING(    0x0000, "2-player Version")
  298.     PORT_DIPSETTING(    0x0004, "3-player Version")
  299.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED )
  300.     PORT_BIT( 0x00f0, IP_ACTIVE_LOW, IPT_UNUSED )
  301.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  302.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  303.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
  304.     PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_VBLANK )
  305.     PORT_BIT( 0xf000, IP_ACTIVE_LOW, IPT_UNUSED )
  306.  
  307.     PORT_START
  308.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SERVICE )
  309.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
  310.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN1 )
  311.     PORT_BIT( 0x00f8, IP_ACTIVE_LOW, IPT_UNUSED )
  312.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  313.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  314.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNUSED )
  315.     PORT_SERVICE( 0x0800, IP_ACTIVE_LOW )
  316.     PORT_BIT( 0xf000, IP_ACTIVE_LOW, IPT_UNUSED )
  317.  
  318.     PORT_START
  319.     PORT_ANALOG( 0x00ff, 0, IPT_TRACKBALL_Y | IPF_REVERSE | IPF_PLAYER2, 100, 30, 0, 0 )
  320.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  321.  
  322.     PORT_START
  323.     PORT_ANALOG( 0x00ff, 0, IPT_TRACKBALL_X | IPF_REVERSE | IPF_PLAYER2, 100, 30, 0, 0 )
  324.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  325.  
  326.     PORT_START
  327.     PORT_ANALOG( 0x00ff, 0, IPT_TRACKBALL_Y | IPF_REVERSE | IPF_PLAYER1, 100, 30, 0, 0 )
  328.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  329.  
  330.     PORT_START
  331.     PORT_ANALOG( 0x00ff, 0, IPT_TRACKBALL_X | IPF_REVERSE | IPF_PLAYER1, 100, 30, 0, 0 )
  332.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  333.  
  334.     PORT_START
  335.     PORT_ANALOG( 0x00ff, 0, IPT_TRACKBALL_Y | IPF_REVERSE | IPF_PLAYER3, 100, 30, 0, 0 )
  336.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  337.  
  338.     PORT_START
  339.     PORT_ANALOG( 0x00ff, 0, IPT_TRACKBALL_X | IPF_REVERSE | IPF_PLAYER3, 100, 30, 0, 0 )
  340.     PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
  341. INPUT_PORTS_END
  342.  
  343.  
  344. INPUT_PORTS_START( ramprt2p )
  345.     PORT_START
  346.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNUSED )
  347.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER3 )
  348.     PORT_BITX(  0x0004, 0x0000, IPT_DIPSWITCH_NAME, "Number of Players", IP_KEY_NONE, IP_JOY_NONE )
  349.     PORT_DIPSETTING(    0x0000, "2-player Version")
  350.     PORT_DIPSETTING(    0x0004, "3-player Version")
  351.     PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED )
  352.     PORT_BIT( 0x00f0, IP_ACTIVE_LOW, IPT_UNUSED )
  353.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  354.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  355.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER3 )
  356.     PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_VBLANK )
  357.     PORT_BIT( 0xf000, IP_ACTIVE_LOW, IPT_UNUSED )
  358.  
  359.     PORT_START
  360.     PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SERVICE )
  361.     PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
  362.     PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN1 )
  363.     PORT_BIT( 0x00f8, IP_ACTIVE_LOW, IPT_UNUSED )
  364.     PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER1 )
  365.     PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER1 )
  366.     PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNUSED )
  367.     PORT_SERVICE( 0x0800, IP_ACTIVE_LOW )
  368.     PORT_BIT( 0xf000, IP_ACTIVE_LOW, IPT_UNUSED )
  369.  
  370.     PORT_START
  371.     PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER2 )
  372.     PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER2 )
  373.     PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_PLAYER2 )
  374.     PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER2 )
  375.     PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER1 )
  376.     PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER1 )
  377.     PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_PLAYER1 )
  378.     PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER1 )
  379.     PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT | IPF_PLAYER3 )
  380.     PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_PLAYER3 )
  381.     PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP | IPF_PLAYER3 )
  382.     PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN | IPF_PLAYER3 )
  383.     PORT_BIT( 0xf000, IP_ACTIVE_HIGH, IPT_UNUSED )
  384.  
  385.     PORT_START
  386.     PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )
  387.  
  388.     PORT_START
  389.     PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )
  390.  
  391.     PORT_START
  392.     PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )
  393.  
  394.     PORT_START
  395.     PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )
  396.  
  397.     PORT_START
  398.     PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNUSED )
  399. INPUT_PORTS_END
  400.  
  401.  
  402.  
  403. /*************************************
  404.  *
  405.  *    Graphics definitions
  406.  *
  407.  *************************************/
  408.  
  409. static struct GfxLayout molayout =
  410. {
  411.     8,8,    /* 8*8 sprites */
  412.     4096,    /* 4096 of them */
  413.     4,        /* 4 bits per pixel */
  414.     { 0, 1, 2, 3 },
  415.     { 0, 4, 8, 12, 16, 20, 24, 28 },
  416.     { 0*8, 4*8, 8*8, 12*8, 16*8, 20*8, 24*8, 28*8 },
  417.     32*8    /* every sprite takes 32 consecutive bytes */
  418. };
  419.  
  420.  
  421. static struct GfxDecodeInfo gfxdecodeinfo[] =
  422. {
  423.     { REGION_GFX1, 0, &molayout,  256, 16 },        /* motion objects */
  424.     { -1 } /* end of array */
  425. };
  426.  
  427.  
  428.  
  429. /*************************************
  430.  *
  431.  *    Sound definitions
  432.  *
  433.  *************************************/
  434.  
  435. static struct OKIM6295interface okim6295_interface =
  436. {
  437.     1,                    /* 1 chip */
  438.     { ATARI_CLOCK_14MHz/4/3/165 },
  439.     { REGION_SOUND1 },
  440.     { 100 }
  441. };
  442.  
  443.  
  444. static struct YM2413interface ym2413_interface =
  445. {
  446.     1,                    /* 1 chip */
  447.     ATARI_CLOCK_14MHz/4,
  448.     { 75 },
  449.     { 0 }
  450. };
  451.  
  452.  
  453.  
  454. /*************************************
  455.  *
  456.  *    Machine driver
  457.  *
  458.  *************************************/
  459.  
  460. static struct MachineDriver machine_driver_rampart =
  461. {
  462.     /* basic machine hardware */
  463.     {
  464.         {
  465.             CPU_M68000,        /* verified */
  466.             ATARI_CLOCK_14MHz/2,
  467.             readmem,writemem,0,0,
  468.             atarigen_video_int_gen,1
  469.         }
  470.     },
  471.     60, DEFAULT_REAL_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  472.     1,
  473.     init_machine,
  474.  
  475.     /* video hardware */
  476.     43*8, 30*8, { 0*8+4, 43*8-1-4, 0*8, 30*8-1 },
  477.     gfxdecodeinfo,
  478.     512,512,
  479.     0,
  480.  
  481.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE | VIDEO_UPDATE_BEFORE_VBLANK | VIDEO_SUPPORTS_DIRTY,
  482.     0,
  483.     rampart_vh_start,
  484.     rampart_vh_stop,
  485.     rampart_vh_screenrefresh,
  486.  
  487.     /* sound hardware */
  488.     0,0,0,0,
  489.     {
  490.         {
  491.             SOUND_OKIM6295,
  492.             &okim6295_interface
  493.         },
  494.         {
  495.             SOUND_YM2413,
  496.             &ym2413_interface
  497.         }
  498.     },
  499.  
  500.     atarigen_nvram_handler
  501. };
  502.  
  503.  
  504.  
  505. /*************************************
  506.  *
  507.  *    ROM decoding
  508.  *
  509.  *************************************/
  510.  
  511. static void rom_decode(void)
  512. {
  513.     int i;
  514.  
  515.     memcpy(&memory_region(REGION_CPU1)[0x140000], &memory_region(REGION_CPU1)[0x40000], 0x8000);
  516.  
  517.     for (i = 0; i < memory_region_length(REGION_GFX1); i++)
  518.         memory_region(REGION_GFX1)[i] ^= 0xff;
  519. }
  520.  
  521.  
  522.  
  523. /*************************************
  524.  *
  525.  *    ROM definition(s)
  526.  *
  527.  *************************************/
  528.  
  529. ROM_START( rampart )
  530.     ROM_REGION( 0x148000, REGION_CPU1 )
  531.     ROM_LOAD_EVEN( "082-1033.13l", 0x00000, 0x80000, 0x5c36795f )
  532.     ROM_LOAD_ODD ( "082-1032.13j", 0x00000, 0x80000, 0xec7bc38c )
  533.     ROM_LOAD_EVEN( "082-2031.13l", 0x00000, 0x10000, 0x07650c7e )
  534.     ROM_LOAD_ODD ( "082-2030.13h", 0x00000, 0x10000, 0xe2bf2a26 )
  535.  
  536.     ROM_REGION( 0x20000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  537.     ROM_LOAD( "082-1009.2n",   0x000000, 0x20000, 0x23b95f59 )
  538.  
  539.     ROM_REGION( 0x40000, REGION_SOUND1 )    /* ADPCM data */
  540.     ROM_LOAD( "082-1007.2d", 0x00000, 0x20000, 0xc96a0fc3 )
  541.     ROM_LOAD( "082-1008.1d", 0x20000, 0x20000, 0x518218d9 )
  542. ROM_END
  543.  
  544.  
  545. ROM_START( ramprt2p )
  546.     ROM_REGION( 0x148000, REGION_CPU1 )
  547.     ROM_LOAD_EVEN( "082-1033.13l", 0x00000, 0x80000, 0x5c36795f )
  548.     ROM_LOAD_ODD ( "082-1032.13j", 0x00000, 0x80000, 0xec7bc38c )
  549.     ROM_LOAD_EVEN( "205113kl.rom", 0x00000, 0x20000, 0xd4e26d0f )
  550.     ROM_LOAD_ODD ( "205013h.rom",  0x00000, 0x20000, 0xed2a49bd )
  551.  
  552.     ROM_REGION( 0x20000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  553.     ROM_LOAD( "10192n.rom",   0x000000, 0x20000, 0xefa38bef )
  554.  
  555.     ROM_REGION( 0x40000, REGION_SOUND1 )    /* ADPCM data */
  556.     ROM_LOAD( "082-1007.2d", 0x00000, 0x20000, 0xc96a0fc3 )
  557.     ROM_LOAD( "082-1008.1d", 0x20000, 0x20000, 0x518218d9 )
  558. ROM_END
  559.  
  560.  
  561. ROM_START( rampartj )
  562.     ROM_REGION( 0x148000, REGION_CPU1 )
  563.     ROM_LOAD_EVEN( "3451.bin",  0x00000, 0x20000, 0xc6596d32 )
  564.     ROM_LOAD_ODD ( "3450.bin",  0x00000, 0x20000, 0x563b33cc )
  565.     ROM_LOAD_EVEN( "1463.bin",  0x40000, 0x20000, 0x65fe3491 )
  566.     ROM_LOAD_ODD ( "1462.bin",  0x40000, 0x20000, 0xba731652 )
  567.     ROM_LOAD_EVEN( "1465.bin",  0x80000, 0x20000, 0x9cb87d1b )
  568.     ROM_LOAD_ODD ( "1464.bin",  0x80000, 0x20000, 0x2ff75c40 )
  569.     ROM_LOAD_EVEN( "1467.bin",  0xc0000, 0x20000, 0xe0cfcda5 )
  570.     ROM_LOAD_ODD ( "1466.bin",  0xc0000, 0x20000, 0xa7a5a951 )
  571.  
  572.     ROM_REGION( 0x20000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  573.     ROM_LOAD( "2419.bin",   0x000000, 0x20000, 0x456a8aae )
  574.  
  575.     ROM_REGION( 0x40000, REGION_SOUND1 )    /* ADPCM data */
  576.     ROM_LOAD( "082-1007.2d", 0x00000, 0x20000, 0xc96a0fc3 )
  577.     ROM_LOAD( "082-1008.1d", 0x20000, 0x20000, 0x518218d9 )
  578. ROM_END
  579.  
  580.  
  581. ROM_START( arcadecr )
  582.     ROM_REGION( 0x148000, REGION_CPU1 )
  583.     ROM_LOAD_EVEN( "pgm0",  0x00000, 0x80000, 0xb5b93623 )
  584.     ROM_LOAD_ODD ( "prog1", 0x00000, 0x80000, 0xe7efef85 )
  585.  
  586.     ROM_REGION( 0x80000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  587.     ROM_LOAD( "atcl_mob",   0x00000, 0x80000, 0x0e9b3930 )
  588.  
  589.     ROM_REGION( 0x80000, REGION_SOUND1 )    /* ADPCM data */
  590.     ROM_LOAD( "adpcm",      0x00000, 0x80000, 0x03ca7f03 )
  591. ROM_END
  592.  
  593.  
  594.  
  595. /*************************************
  596.  *
  597.  *    Driver initialization
  598.  *
  599.  *************************************/
  600.  
  601. static void init_rampart(void)
  602. {
  603.     static const UINT16 compressed_default_eeprom[] =
  604.     {
  605.         0x0001,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0150,0x0101,
  606.         0x0100,0x0151,0x0300,0x0151,0x0400,0x0150,0x0101,0x01FB,
  607.         0x021E,0x0104,0x011A,0x0200,0x011A,0x0700,0x01FF,0x0E00,
  608.         0x01FF,0x0E00,0x01FF,0x0150,0x0101,0x0100,0x0151,0x0300,
  609.         0x0151,0x0400,0x0150,0x0101,0x01FB,0x021E,0x0104,0x011A,
  610.         0x0200,0x011A,0x0700,0x01AD,0x0150,0x0129,0x0187,0x01CD,
  611.         0x0113,0x0100,0x0172,0x0179,0x0140,0x0186,0x0113,0x0100,
  612.         0x01E5,0x0149,0x01F8,0x012A,0x019F,0x0185,0x01E7,0x0113,
  613.         0x0100,0x01C3,0x01B5,0x0115,0x0184,0x0113,0x0100,0x0179,
  614.         0x014E,0x01B7,0x012F,0x016D,0x01B7,0x01D5,0x010B,0x0100,
  615.         0x0163,0x0242,0x01B6,0x010B,0x0100,0x01B9,0x0104,0x01B7,
  616.         0x01F0,0x01DD,0x01B5,0x0119,0x010B,0x0100,0x01C2,0x012D,
  617.         0x0142,0x01B4,0x010B,0x0100,0x01C5,0x0115,0x01BB,0x016F,
  618.         0x01A2,0x01CF,0x01D3,0x0107,0x0100,0x0192,0x01CD,0x0142,
  619.         0x01CE,0x0107,0x0100,0x0170,0x0136,0x01B1,0x0140,0x017B,
  620.         0x01CD,0x01FB,0x0107,0x0100,0x0144,0x013B,0x0148,0x01CC,
  621.         0x0107,0x0100,0x0181,0x0139,0x01FF,0x0E00,0x01FF,0x0E00,
  622.         0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,
  623.         0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,
  624.         0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,0x01FF,0x0E00,
  625.         0x0000
  626.     };
  627.  
  628.     atarigen_eeprom_default = compressed_default_eeprom;
  629.     slapstic_init(118);
  630.  
  631.     /* set up some hacks to handle the slapstic accesses */
  632.     cpu_setOPbaseoverride(0,opbase_override);
  633.  
  634.     /* display messages */
  635.     atarigen_show_slapstic_message();
  636.  
  637.     rom_decode();
  638. }
  639.  
  640.  
  641. static void init_arcadecr(void)
  642. {
  643.     UINT32 length = 0x80000 * 2;
  644.     UINT16 *data = (UINT16 *)memory_region(REGION_CPU1);
  645.     UINT8 *temp1 = malloc(length / 2), *temp2 = malloc(length / 2);
  646.     FILE *f;
  647.     int i;
  648.  
  649.     atarigen_eeprom_default = NULL;
  650.  
  651. /*
  652.     Issues:
  653.  
  654.     * Rampart has 16k of RAM (2 x 8K chips); Classics has 64k
  655.     * Rampart has 128k of MOBs; Classics has 512k (see schematics for resistor combinations)
  656.     * Rampart has 256k of ADPCM; Classics has 512k (see schematics again)
  657.     * latch is at same address for both, but Rampart only has on/off for ADPCM
  658.       while classics has 0-31
  659.     * moved watchdog from 647000 to 720000
  660.         33C0 0064 7000      -> 33C0 0072 0000
  661.     * moved interrupt ack from 646000 to 7e0000
  662.         33FC 0000 0064 6000 -> 33FC 0000 007e 0000
  663.         33C0 0064 6000      -> 33C0 007e 0000
  664.     * moved ADPCM from 642000 to 460000
  665.         2D7C 0064 2000      -> 2D7C 0046 0000
  666.     * changed btst #7,$640011 to btst #3,$640000
  667.         0839 0007 0064 0011 -> 0839 0003 0064 0000
  668.     * changed btst #6,$640011 to btst #0,$640003
  669.         0839 0006 0064 0011 -> 0839 0000 0064 0003
  670. */
  671.     for (i = 0; i < length - 8; i += 2, data++)
  672.     {
  673.         if (data[0] == 0x33c0 && data[1] == 0x0064 && data[2] == 0x7000)
  674.             data[1] = 0x0072, data[2] = 0x0000;
  675.         else if (data[0] == 0x33fc && data[1] == 0x0000 && data[2] == 0x0064 && data[3] == 0x6000)
  676.             data[2] = 0x007e, data[3] = 0x0000;
  677.         else if (data[0] == 0x33c0 && data[1] == 0x0064 && data[2] == 0x6000)
  678.             data[1] = 0x007e, data[2] = 0x0000;
  679.         else if (data[0] == 0x2d7c && data[1] == 0x0064 && data[2] == 0x2000)
  680.             data[1] = 0x0046, data[2] = 0x0000;
  681.         else if (data[0] == 0x0839 && data[1] == 0x0007 && data[2] == 0x0064 && data[3] == 0x0011)
  682.             data[1] = 0x0003, data[3] = 0x0000;
  683.         else if (data[0] == 0x0839 && data[1] == 0x0006 && data[2] == 0x0064 && data[3] == 0x0011)
  684.             data[1] = 0x0000, data[3] = 0x0003;
  685.         temp1[i / 2] = data[0] >> 8;
  686.         temp2[i / 2] = data[0];
  687.     }
  688.  
  689.     f = fopen("pgm0.bin", "wb");
  690.     fwrite(temp1, 1, length / 2, f);
  691.     fclose(f);
  692.     f = fopen("pgm1.bin", "wb");
  693.     fwrite(temp2, 1, length / 2, f);
  694.     fclose(f);
  695.  
  696.     for (i = 0; i < memory_region_length(REGION_GFX1); i++)
  697.         memory_region(REGION_GFX1)[i] ^= 0xff;
  698. }
  699.  
  700.  
  701.  
  702. /*************************************
  703.  *
  704.  *    Game driver(s)
  705.  *
  706.  *************************************/
  707.  
  708. GAME( 1990, rampart,  0,       rampart, rampart,  rampart, ROT0, "Atari Games", "Rampart (3-player Trackball)" )
  709. GAME( 1990, ramprt2p, rampart, rampart, ramprt2p, rampart, ROT0, "Atari Games", "Rampart (2-player Joystick)" )
  710. GAME( 1990, rampartj, rampart, rampart, ramprt2p, rampart, ROT0, "Atari Games", "Rampart (Japan, 2-player Joystick)" )
  711.  
  712. GAME( 1990, arcadecr, rampart, rampart, rampart,  arcadecr,ROT0, "Atari Games", "Arcade Classics (Rampart PCB)" )
  713.